from LeetCoder import *


class Solution:

    def circularGameLosers(self, n: int, k: int) -> List[int]:
        b = [False] * (n + 1)

        def f(index, t):
            if b[index]:
                return
            b[index] = True
            t += 1
            move = (t * k) % n
            index += move
            if index > n:
                index %= n
            f(index, t)

        f(1, 0)
        ans = []
        for i, v in enumerate(b):
            if not v and i != 0:
                ans.append(i)
        return ans


s = Solution()
print(s.circularGameLosers(n=2, k=1))
print(s.circularGameLosers(n=12, k=1))
# [3,5,6,8,9,10,12]
print(s.circularGameLosers(n=1, k=1))
print(s.circularGameLosers(n=5, k=2))
print(s.circularGameLosers(n=4, k=4))
# print(10 % 3)
